// Scope.cpp

#include "scope.h"
#include <iostream>

class Scope::ScopeImpl {
public:
    explicit ScopeImpl(int tempreture);
    ~ScopeImpl() = default;

    int GetOrientation() const;
private:
    int mTempreture = 0;
};

Scope::ScopeImpl::ScopeImpl(int tempreture) : mTempreture(tempreture) {
}

int Scope::ScopeImpl::GetOrientation() const {
    return this->mTempreture;
}

// Scope::Scope(int tempreture) {
//     this->pImpl = new ScopeImpl(tempreture);
// }

// for unique_ptr member std::unique_ptr<ScopeImpl> pImpl;
Scope::Scope(int tempreture) : pImpl(std::make_unique<ScopeImpl>(tempreture)) {}

// // for ScopeImpl* Scope:: pImpl
// Scope::~Scope() {
//   std::cout << "Scope::~Scope\n";
//   if (this->pImpl) {
//       delete this->pImpl;
//       this->pImpl = nullptr;
//   }
// }

// 为了使  Scope 类中 std::unique_ptr<ScopeImpl> pImpl; 的声明能编译通过
Scope::~Scope() = default;

int Scope::GetOrientation() const {
    return this->pImpl->GetOrientation();
}
